﻿using MongoDAO.Configuration;
using MongoDB.Driver;

namespace MongoDAO.Providers
{
    public class MongoDatabaseProvider
    {
        private readonly MongoDatabase _database;

        public MongoDatabaseProvider() : this("MongoServerSettings")
        {
        }
        
        public MongoDatabaseProvider(string connectionStringName)
        {
            var _serverProvider = new MongoServerProvider(MongoConfigurationSettings.GetConnectionString(connectionStringName));
            var _mongoUrl = new MongoUrl(_serverProvider.GetConnectionString());
            _database = _serverProvider.GetServer().GetDatabase(_mongoUrl.DatabaseName);
        }

        public MongoDatabase GetDatabase()
        {
            return _database;
        }

    }
}
